# from django.contrib import admin
# from .models import Category, SubCategory, Skill
#
#
# @admin.register(Category)
# class CategoryAdmin(admin.ModelAdmin):
#     """主分类管理"""
#     list_display = ['name', 'order', 'is_active', 'created_at']
#     list_filter = ['is_active', 'created_at']
#     search_fields = ['name']
#     ordering = ['order', 'id']
#
#
# @admin.register(SubCategory)
# class SubCategoryAdmin(admin.ModelAdmin):
#     """子分类管理"""
#     list_display = ['name', 'category', 'order', 'is_active', 'created_at']
#     list_filter = ['category', 'is_active', 'created_at']
#     search_fields = ['name', 'category__name']
#     ordering = ['category', 'order', 'id']
#     raw_id_fields = ['category']  # 对于ForeignKey字段，使用raw_id_fields可以更方便选择
#
#
# @admin.register(Skill)
# class SkillAdmin(admin.ModelAdmin):
#     """技能/角色管理"""
#     list_display = ['name', 'subcategory', 'get_category', 'order', 'is_active', 'created_at']
#     list_filter = ['subcategory__category', 'subcategory', 'is_active', 'created_at']
#     search_fields = ['name', 'subcategory__name', 'subcategory__category__name']
#     ordering = ['subcategory__category', 'subcategory', 'order', 'id']
#     raw_id_fields = ['subcategory']  # 对于ForeignKey字段，使用raw_id_fields可以更方便选择
#
#     def get_category(self, obj):
#         """获取所属的主分类"""
#         return obj.subcategory.category.name
#     get_category.short_description = "主分类"
#     get_category.admin_order_field = 'subcategory__category__name'
